// body宽高
let cw = 1850, ch = 1250;
let body = document.getElementById('body');
body.style.width = `${cw}px`;
body.style.height = `${ch}px`;

// body缩放
function windowResize() {
  // 窗口宽高
  let w = window.innerWidth, h = window.innerHeight;
  // 缩放比例
  let r = w / cw < h / ch ? w / cw : h / ch;
  body.style.transform = `scale(${r})`;
  body.style.marginLeft = (-(cw - r * cw) / 2 + (w - r * cw) / 2) + 'px';
  body.style.marginTop = (-(ch - r * ch) / 2 + (h - r * ch) / 2) + 'px';
  body.style.marginBottom = (-(h > ch ? h : ch - r * ch)) + 'px';
  body.style.marginRight = (-(w > cw ? w : cw - r * cw)) + 'px';
}
windowResize();
// 监听窗口尺寸变化
window.addEventListener('resize', windowResize);

